<?php
    
class ConfigFile{
    
    private $SettingsDir = '/conf/';    
    private $Config;
    private $ServerName;
    
    
    public function __construct(){
        
        if($_SERVER['HTTP_HOST'] == 'gregorpilz.de'){
            $root = '/';
        }else{
            $root = '/test';
        }
        
        $this->Config = include $_SERVER['DOCUMENT_ROOT'].$root.$this->SettingsDir.'setting.php';
               
        $this->getServerName();
        
        if (is_file($_SERVER['DOCUMENT_ROOT'].$root.$this->SettingsDir.$this->ServerName.'.php')) {
        	$tmps = include $_SERVER['DOCUMENT_ROOT'].$root.$this->SettingsDir.$this->ServerName.'.php';
 
        	foreach ($tmps as $key => $live){
        		if(array_key_exists($key, $this->Config)){
        			$this->Config[$key] = $live; 
        		}
        	}
        }
    }
   
    
    public static function Load(){
        return new ConfigFile();        
    }
    
    public function getServerName(){
        $this->ServerName = str_replace("www.", "", $_SERVER['HTTP_HOST']);
    }
    
    public static function Get($key){
        $configclass = self::Load();   
	    
        if(array_key_exists($key,$configclass->Config))
        {            
            return $configclass->Config[$key];
        }
        else
        {
            return true;          
        }        
    }
    
}